/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modele;

/**
 * @author Hadrien
 */
public class RERTicket extends Order {

    public var reduceFare: Boolean = false on replace { computePrice() };
    public var startStation: String = "" on replace { computePrice() };
    public var endStation: String = "" on replace { computePrice() };
    override public var description = bind "{quantity} Ticket RER / {if (reduceFare) "Tarif réduit" else "Plein tarif"}\n{startStation}\n{endStation}";

    init {
        price = if (reduceFare) 6.0 else 12.0;
        name = "Paris region ticket";
    }

    override public function deliver(): Void {
        for (i in [1..quantity]) {
            println("Print a {name} from {startStation} to {endStation} {if (reduceFare) "reduce fare" else "full fare"})");
        }
    }

    function computePrice() : Void {
        price = if (reduceFare) 6.0 else 12.0;
    }

}
